import pyautogui
import time

# 设置入口的坐标位置
def get_position(times):
    # times为需要打印多少次坐标
    for i in range(times):
        print("当前鼠标的坐标为：", pyautogui.position())  # 循环执行pyautogui.position()获取不同位置坐标
        time.sleep(2)

def AutoOpen(times):
    position = (808, 1056)
    com6 = (132, 268)
    com6_1 = (108, 291)
    min = (1805, 9)
    position = [position, com6, com6_1, min]  # 将坐标位置的值存储为列表
    for i in position:
        pyautogui.moveTo(i)
        pyautogui.click(clicks=2)
        time.sleep(1)
    for i in range(times + 1):  # times + 1 为想要运行的次数
        try:
            pyautogui.click(clicks=1)
            time.sleep(1)  # 页面操作过快可能电脑没反应过来  每次操作间隔1S
        except:
            continue  # 如果运行失败，则结束本次循环继续下一次循环

def AutoClose(times):
    position = (808, 1056)
    com_close = (569, 110)
    pyautogui.click(position)
    time.sleep(1)
    pyautogui.click(com_close)
    time.sleep(1)


if __name__ == '__main__':
    #get_position(5)  #调用获取鼠标坐标的方法，确认对应坐标后可不调用该方法
    AutoOpen(1)
    AutoClose(2)
